package com.tengju.user.infrastructure.repository.convert;

import com.tengju.user.domain.model.survey.SurveyConfigInfo;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.SurveyConfigDO;

import java.util.Date;

public class SurveyConfigConvert {

    public static SurveyConfigDO convertToDO(Long id,SurveyConfigInfo surveyConfigInfo) {
        SurveyConfigDO surveyConfigDO = new SurveyConfigDO();
        surveyConfigDO.setId(id);
        surveyConfigDO.setSurveyId(surveyConfigInfo.getSurveyId().getValue());
        surveyConfigDO.setSurveyTitle(surveyConfigInfo.getSurveyTitle());
        surveyConfigDO.setItemCode(surveyConfigInfo.getItemCode());
        surveyConfigDO.setItemOrder(surveyConfigInfo.getItemOrder());
        surveyConfigDO.setItemTitle(surveyConfigInfo.getItemTitle());
        surveyConfigDO.setQueryTitle(surveyConfigInfo.getQueryTitle());
        surveyConfigDO.setItemType(surveyConfigInfo.getItemType().getCode());
        surveyConfigDO.setItemRequired(surveyConfigInfo.getItemRequired());
        surveyConfigDO.setCreateBy(surveyConfigInfo.getCreateBy());
        surveyConfigDO.setUpdateBy(surveyConfigInfo.getUpdateBy());
        surveyConfigDO.setItemParams(surveyConfigInfo.getItemParams());
        surveyConfigDO.setMsgType(surveyConfigInfo.getMsgType().getVal());
        surveyConfigDO.setCreateTime(new Date());
        surveyConfigDO.setUpdateTime(new Date());
        return surveyConfigDO;
    }


}
